#
from typing import Dict, List
import logging
from dbs.mysql_engine import MysqlEngine

# 配置日志记录
logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)

class OptionDao(object):
    def __init__(self):
        self.name = 'dbs.option_dao.OptionDao'
    
    @staticmethod
    def add_option(params:Dict = {}) -> None:
        sql_params = []
        sql_params.append(params['opt_text'])
        sql = 'INSERT INTO z_opt(opt_text) VALUES(%s)'
        option_id = MysqlEngine.add_rec(sql, sql_params)
        print(f'###### 选项编号：{option_id}; v0.0.1 ???????????')

    @staticmethod
    def get_qstn_options(qstn_id) -> List:
        sql = 'SELECT opt_text FROM z_opt'
        params = ()
        recs = MysqlEngine.query(sql, params)
        return recs